﻿using Furion.DynamicApiController;
using HOPU.OnlineSchool.Application.Users.Dtos;
using HOPU.OnlineSchool.Application.Users.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HOPU.OnlineSchool.Application.Users
{
    /// <summary>
    /// 用户接口
    /// </summary>
    public class UserAppService : IDynamicApiController
    {
        private readonly IUserService _userService;

        public UserAppService(IUserService userService)
        {
            _userService = userService;
        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        public async Task<LoginJwtDto> Login([FromBody] LoginInfoInput input)
        {
            return await _userService.LoginAsync(input);
        }
        /// <summary>
        /// 退出登录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Logout()
        {
            return  _userService.Logout();
        }
        /// <summary>
        /// 获取登录用户信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public LoginSuccessDto Info()
        {
            return _userService.Info();
        }
      
    }
}
